package org.icnmasjid.member.model;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * @hibernate.class table="person_relationship"
 * @author faiz
 *
 */
public class PersonRelation extends BaseObject {

	private Integer id;
	private Person person;
	private Person relatedPerson;
	private RelationshipType relationshipType;

	public PersonRelation() {
		super();
	}

    /**
     *      *            @hibernate.id
     *             generator-class="native"
     *             type="java.lang.Integer"
     *             column="id"
     *
     */

    public Integer getId() {
        return this.id;
    }

	public void setId(Integer id) {
		this.id = id;
	}


	/**
	 * @hibernate.many-to-one
	 * 	not-null="true"
	 * 	class="org.icnmasjid.member.model.Person"
	 * 	column="person_id"
	 */
	public Person getPerson() {
		return person;
	}

	public void setPerson(Person person) {
		this.person = person;
	}

	/**
	 * @hibernate.many-to-one
	 *  not-null="true"
	 * 	class="org.icnmasjid.member.model.Person"
	 * 	column="related_person_id"
	 */
	public Person getRelatedPerson() {
		return relatedPerson;
	}

	public void setRelatedPerson(Person relatedPerson) {
		this.relatedPerson = relatedPerson;
	}

	/**
	 * @hibernate.many-to-one
	 * 	class="org.icnmasjid.member.model.RelationshipType"
	 * 	not-null="true"
	 * 	column="relationship_type_id"
	 */
	public RelationshipType getRelationshipType() {
		return relationshipType;
	}

	public void setRelationshipType(RelationshipType relationshipType) {
		this.relationshipType = relationshipType;
	}


	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
				.append("id", this.id).append("person", this.person).append(
						"relationshipType", this.relationshipType).append(
						"relatedPerson", this.relatedPerson).toString();
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 0;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((person == null) ? 0 : person.hashCode());
		result = prime * result
				+ ((relatedPerson == null) ? 0 : relatedPerson.hashCode());
		result = prime
				* result
				+ ((relationshipType == null) ? 0 : relationshipType.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (getClass() != obj.getClass())
			return false;
		final PersonRelation other = (PersonRelation) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (person == null) {
			if (other.person != null)
				return false;
		} else if (!person.equals(other.person))
			return false;
		if (relatedPerson == null) {
			if (other.relatedPerson != null)
				return false;
		} else if (!relatedPerson.equals(other.relatedPerson))
			return false;
		if (relationshipType == null) {
			if (other.relationshipType != null)
				return false;
		} else if (!relationshipType.equals(other.relationshipType))
			return false;
		return true;
	}


}